package com.wyx.suanfa;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class trap {
    //给定 n 个非负整数表示每个宽度为 1 的柱子的高度图，计算按此排列的柱子，下雨之后能接多少雨水
    public static void main(String[] args) {

    }
}
/*
* class Solution {
    public int trap(int[] height) {
        if(height.length <= 2){
            return 0;
        }
        int len = height.length;
        int[] maxLeft = new int[len];
        int[] maxRight = new int[len];

        maxLeft[0] = height[0];
        for(int i = 1;i<len;i++){
            maxLeft[i] = Math.max(height[i],maxLeft[i - 1]);
        }
        maxRight[len - 1] = height[len - 1];
        for(int i = len - 2;i>=0;i--){
            maxRight[i] = Math.max(height[i],maxRight[i + 1]);
        }
        int sum = 0;
        for(int i = 0;i<len;i++){
            int count = Math.min(maxLeft[i],maxRight[i]) - height[i];
            if(count > 0){
                sum += count;
            }
        }
        return sum;


    }
}*/
